//! 下拉框
<template>
  <el-select @change="changeChannel" clearable :value="value" placeholder="请选择">
    <el-option v-for="item in channelOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
  </el-select>
</template>

<script>
export default {
  name: 'my-channel',
  props: ['value'],
  data () {
    return {
      // value: null,
      channelOptions: []
    }
  },
  created () {
    this.getChannelOptions()
  },
  methods: {
    // 值改变事件
    changeChannel (channelId) {
      if (channelId === '') channelId = null
      this.$emit('input', channelId)
    },
    async getChannelOptions () {
      //! 此处为获取下拉框选项的请求并且拿到数据(函数名需要自行更改)
      // const {
      //   data: { data }
      // } = await getChannels()
      // this.channelOptions = data.channels
    }
  }
}
</script>

<style scoped lang="scss"></style>
